<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use ZigaStrgar\Orderable\Orderable;
use Illuminate\Database\Eloquent\SoftDeletes;
class Progress extends Model
{
    use Orderable;
    use SoftDeletes;
    protected $dates = ['deleted_at'];
    protected $table = 'progress';
    public $timestamps = false;
    protected $fillable = ['product_id','claim_state','created_at','updated_at','user_id','progress_list_id','first_type_id','second_type_id','is_push','is_renew','order'];
    /**
     * 排序方法，默认排序desc
     * @return array
     */
    public function orderable()
    {
        return [
            'is_cancel'=>'ASC',
            'progress.updated_at' => 'DESC',
        ];
    }
    public function FirstType()
    {
        return $this->belongsTo('App\Models\FirstType','first_type_id');
    }
    public function SecondType()
    {
        return $this->belongsTo('App\Models\SecondType','second_type_id');
    }
    public function Product()
    {
        return $this->belongsTo('App\Models\Product','product_id',"id");
    }
    public function ProgressList()
    {
        return $this->belongsTo('App\Models\ProgressList','progress_list_id');
    }


    public function Progress()
    {
        return $this->hasMany('App\Models\ProgressList','second_type_id',"second_type_id");
    }

    public function Admin()
    {
        return $this->belongsTo('App\Models\Admin','admin_id');
    }

    public function User()
    {
        return $this->belongsTo('App\Models\User','user_id');
    }

}
